filesize 0.1.0

Find the physical space used by a file
Documentation

filesize

Cargo Build Status

Physical disk space use retrieval.

filesize abstracts platform-specific methods of determining the real space used by files, taking into account filesystem compression and sparse files.

use filesize::{file_real_size, file_real_size_fast};

let realsize = file_real_size("Cargo.toml")?;

// Save a stat() on Unix
let also_realsize = file_real_size_fast(
    "Cargo.toml",
    &std::fs::symlink_metadata("Cargo.toml")?
)?;

Now, please stop writing du clones that only take apparent size into account.

Supported Platforms

Unix

On Unix platforms this is a thin wrapper around std::fs::symlink_metadata() and std::os::unix::fs::MetadataExt, simply returning blocks() * 512.

Windows

On Windows this wraps GetCompressedFileSizeW().

Everything Else

All other platforms receive a fallback that simply returns the logical file size.